package com.decelo.jpa.controller;

import com.decelo.jpa.entity.sys.Classes;
import com.decelo.jpa.result.Result;
import com.decelo.jpa.result.ResultCode;
import com.decelo.jpa.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value="/classes")
@Validated
public class ClassesController {
    @Autowired
    private ClassesService classesService;

    @RequestMapping(value="/add",method= RequestMethod.POST,produces="application/json")
    public Result add(HttpServletRequest request,@RequestBody @Validated Classes classes){
        Result result=new Result();
        boolean bool = classesService.edit(classes);
        if (bool){
            result.setCode(ResultCode.CODE_200.getCode());
            result.setMsg(ResultCode.CODE_200.getMsg());
            result.setObject(true);
        }else{
            result.setCode(ResultCode.CODE_500.getCode());
            result.setMsg(ResultCode.CODE_500.getMsg());
            result.setObject(false);
        }
        return result;
    }

}
